<?php
declare (strict_types = 1);

namespace app\controller;

use app\BaseController;
use app\model\Feedback;
use app\model\FeedbackClass;
use app\Request;

class FeedbackController extends BaseController
{

    protected array $middleware = [
        'Login' => ['except' => ['class']],
    ];


    /**
     * 反馈记录
     * @param Request $request
     */
    function index(Request $request)
    {
        $rows = Feedback::where(['users_id'=>$request->users_id])->order(['id'=>'desc'])->paginate()->items();
        writeJson($rows);
    }
    
    /**
     * 反馈
     * @param Request $request
     * @return \think\response\Json
     */
    public function save(Request $request)
    {
        $pamars = $request->param();
        Feedback::create($pamars);
        writeJson();
    }

    /**
     * 反馈分类
     * @return \think\response\Json
     */
    public function class()
    {
        $rows = FeedbackClass::select();
		writeJson($rows);
    }
	
}
